
 
 F u n c t i o n :   $ A ( d o m E l e m e n t O r M a r k u p S t r i n g O r C S S S e l e c t o r ) 
 
 
 
 D e s c r i p t i o n :   C r e a t e   a n d   r e t u r n   a   $ A   C h a i n   O b j e c t . 
 
 
 
 R e t u r n s :   $ A   C h a i n   O b j e c t . 
 
 
 
 N o t e :   A l l   C h a i n   o b j e c t s   m a p   t o   t h e   $ A   ( 4 X )   A P I ,   a n d   c a n   b e   c h a i n e d   t o g e t h e r   t o   c r e a t e   c o m p l e x   c h a i n i n g   s t a t e m e n t s .   I f   t h e   a r g u m e n t   p a s s e d   t o   $ A ( )   i s   b o u n d   a s   t h e   I D   o f   a   D C   o b j e c t   h o w e v e r ,   t h e   D C   o b j e c t   w i l l   b e   r e t u r n e d   i n s t e a d .   W h e n   a   D C   o b j e c t   i s   r e t u r n e d ,   i t   t h e n   m a p s   t o   t h e   D C   A P I .   W h e n   c h a i n e d ,   s t r i n g   m a r k u p   w i l l   a u t o m a t i c a l l y   b e   c o n v e r t e d   i n t o   a   D O M   n o d e   f r a g m e n t ,   o r   C S S   s e l e c t o r e s   w i l l   q u e r y   t h e   t a r g e t t e d   e l e m e n t s   t o   r e f e r e n c e   t h o s e   t h a t   m a t c h . 
 
 
 
 E x a m p l e : 
 
 
 
 / /   C r e a t e   a   c h a i n   o b j e c t   u s i n g   a   D O M   e l e m e n t . 
 
 v a r   m y C h a i n   =   $ A ( d o m E l e m e n t ) ; 
 
 
 
 / /   C r e a t e   a   c h a i n   o b j e c t   u s i n g   a   C S S   s e l e c t o r   t o   l o c a t e   t h e   f i r s t   d i v   w i t h   t h e   c l a s s   " e r r o r S e c t i o n " ,   a n d   m o v e   f o c u s   t o   i t . 
 
 v a r   m y C h a i n   =   $ A ( " d i v . e r r o r S e c t i o n " ) . f o c u s ( ) ; 
 
 
 
 / /   C r e a t e   a   D O M   f r a g m e n t   r e a d y   f o r   c h a i n i n g   w i t h   a d d i t i o n a l   m e t h o d s . 
 
 v a r   m y C h a i n   =   $ A ( ' < b u t t o n   c l a s s = " t o g g l e B t n " > S e t t i n g s < / b u t t o n > ' ) 
 
 / /   T h e n   s e t   a t t r i b u t e s   o n   t h e   n e w   o b j e c t   s t o r e d   w i t h i n   t h e   c h a i n . 
 
 . s e t A t t r i b u t e ( { 
 
     " a r i a - p r e s s e d " :   " f a l s e " 
 
 } ) 
 
 / /   T h e n   b i n d   e v e n t s   t o   t h e   o b j e c t   w i t h i n   t h e   c h a i n . 
 
 . o n ( { 
 
     c l i c k :   f u n c t i o n ( e )   { 
 
         $ A ( t h i s ) . t o g g l e C l a s s ( " p r e s s e d " ,   f u n c t i o n ( s t a t e I s T r u e )   { 
 
             / /   C h a n g e   a s s o c i a t e d   a t t r i b u t e   t o   m a t c h   t h e   t o g g l e   c l a s s   s t a t e   f r o m   w i t h i n   t h e   c a l l b a c k . 
 
             $ A ( t h i s ) . s e t A t t r i b u t e ( " a r i a - p r e s s e d " ,   s t a t e I s T r u e   ?   " t r u e "   :   " f a l s e " ) ; 
 
         } ) ; 
 
     } 
 
 } ) 
 
 / /   T h e n   i n s e r t   t h e   n e w   o b j e c t   a s   m o d i f i e d   b e f o r e   t h e   f i r s t   H 1   e l e m e n t   o n   t h e   p a g e   u s i n g   a   C S S   s e l e c t o r . 
 
     . b e f o r e ( " h 1 " ) ; 
 
 
 
 / /   R e t u r n   t h e   m o d i f i e d   o b j e c t   w i t h i n   a   c h a i n . 
 
 v a r   d o m E l e m e n t   =   m y C h a i n . r e t u r n ( ) ; 
 
 